
if [ $1 -eq 0 ]
then
    tc qdisc del dev enp0s5 root
    echo "qdisc del dev enp0s5 root"
else
    # speed in Mbps
    SPEED=$1
    KB_SPEED=$(echo "($SPEED * 1000) / 1" | bc)

    # in bytes. Must be atleast 1500 bytes (1 packet)
    BUFFER_SIZE=$2

    #todo add delay
    tc qdisc replace dev enp0s5 root tbf rate $KB_SPEED.kbit limit $BUFFER_SIZE burst 12kbit
    echo "tc qdisc replace dev enp0s5 root tbf rate ${KB_SPEED}.kbit limit ${BUFFER_SIZE} burst 12kbit"
fi

tcpdump -i enp0s5 host 192.168.1.167 -s 80 -w vm_enp0s5_$1_$2.pcap &
tcpdump -i wlx8416f9171bbc host 192.168.1.167 -s 80 -w vm_wlx8416f9171bbc_$1_$2.pcap &
sleep 3
./saturatr 192.168.1.125 wlx8416f9171bbc 10.211.55.3 enp0s5 192.168.1.167 &
sleep 30
pkill -9 saturatr
sleep 2
pkill -9 tcpdump
